﻿using Common;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using StudentManager.API.ViewMode;
using StudentManager.Data.IDAL;
using StudentManager.Data.Model;
using System.Runtime.InteropServices;

namespace StudentManager.API.BLL
{
    [Service(EServLife.Scoped)]
    public class StudentExBO([FromServices] IStudentDAO stuDAO) 
    {

        public IResult Add(StudentInfo studentInfo)
        {
            var student = new Student
            {
                StudentID = studentInfo.StudentID,
                StudentNo = studentInfo.StudentNo,
                Sex = studentInfo.Sex,
                Class = studentInfo.Class,
                Grade = studentInfo.Grade,
                Major = studentInfo.Major,
                Mobile = studentInfo.Mobile,
                Name = studentInfo.Name,
                Password = studentInfo.Password,
                Photo = studentInfo.Photo,
            };
            var kk = stuDAO.Insert(student);
            if(kk > 0)
            {
                return Result.OK("学生信息添加成功");
            }
            else
            {
                return Result.OK("信息添加失败");
            }
        }
        public IResult GetInfo(int id)
        {
            var record = stuDAO.GetInfo(id);
            return Result.Data(record);
        }
    }
}
